package com.example.demo.client;

import org.json.JSONObject;

public class ProcessData {
    public static String message(String data) {
        JSONObject jsonObject = new JSONObject(data);
        JSONObject Data = new JSONObject();
        if (jsonObject.has("message_type")){
            Data.put("type",jsonObject.getString("message_type"));
            Data.put("msg",jsonObject.getString("raw_message"));
            String id = jsonObject.has("group_id")?Long.toString(jsonObject.getLong("group_id")):Long.toString(jsonObject.getLong("user_id"));
            Data.put("id",id);
            Data.put("user",jsonObject.getLong("user_id"));
//        System.out.println(data);
        }
        // 处理数据
        return Data.toString();
    }
}
